#include <iostream>
using namespace std;
const int BUFFER_SIZE = 32;
/*无参构造函数想要调用有参构造函数必须使用初始化列表*/
class Student
{
public:
#if 1
    Student()
    {
        cout << "Student父类无参构造\n";
    }
#endif
    ~Student()
    {
        cout << "Student父类析构函数\n";
    }
    Student(int age) : m_age(age)
    {
        cout << "Student父类带参构造\n";
    }

public:
    int m_age;
};

class Worker
{
public:
    Worker()
    {
        cout << "Worker无参构造\n";
    }
    Worker(int no) : m_no(no)
    {
        cout << "Worker带参构造\n";
    }
    ~Worker()
    {
        cout << "Worker析构函数\n";
    }

public:
    int m_no;
};

class Undergraduate : public Student, public Worker
{
public:
    Undergraduate(int age, int no, int hair) : Student(age), Worker(no), m_hair(hair)
    {
        cout << "Undergraduate子类带参构造\n";
    }
    ~Undergraduate()
    {
        cout << "Undergraduate子类析构函数\n";
    }
    void play()
    {
        cout << "Undergraduate play\n";
    }

public:
    int m_hair;
};

int main()
{
    /*子类的内存顺序是根据继承的顺序而不是程序顺序*/
    Undergraduate ug(10, 20, 30);
    int len = sizeof(ug);
    cout << len << endl;
    cout << ug.m_age << endl;
    cout << ug.m_hair << endl;
    cout << ug.m_no << endl;
    return 0;
}